from collections import Counter

if __name__ == '__main__':
    # 实例化元素为空的 Counter 对象
    a = Counter()
    # 为 Counter 添加元素以及对应的 count 计数
    a['a'] = 1
    a['b'] = 2
    a['c'] = 3
    print(a)
    # 从可迭代对象中实例化 Counter 对象
    b = Counter('chenkc')
    print(b)
    # 从 mapping 中实例化 Counter 对象
    c = Counter({'a': 1, 'b': 2, 'c': 3})
    # 从关键词参数中实例化 Counter 对象
    d = Counter(a=1, b=2, c=3)
    # list
    b2 = Counter(['c', 'h', 'e', 'n', 'k', 'c'])
    print(b2)
    # tuple
    b3 = Counter(('c', 'h', 'e', 'n', 'k', 'c'))
    print(b3)